#ifndef INVOICESPARSER_H
#define INVOICESPARSER_H

#include "InvoiceItem.h"
#include "Shop.h"

namespace ecocity
{

class InvoicesParser
{
    enum COLUMN
    {
        DATE                   = 0,
        CUSTOMER_ID            = 1,
        CUSTOMER_NAME          = 2,
        INVOICE_ITEM           = 3 //amd more
    };

    enum COLUMN_INVOICE_ITEM
    {
        QUANTITY                   = 0,
        WEIGHT                     = 1,
        DISCOUNT_RATE              = 2,
        PRODUCT_ID                 = 3,
        PRODUCT_NAME               = 4
    };

public:

    static void append_invoice( const ecocity::Invoice& invoice,
                                const QString& file_name );

    static bool parse( const QString& file_invoices_csv,
                       Shop* shop );

    static std::vector< int > separators_in_line( const QString& line,
                                                  const char separator = ';' );



private:

    static bool parse_file( QFile& stream,
                            Shop* shop );

    static void parse_line( const QString& line,
                            Shop* shop,
                            const char separator = ';' );

    static InvoiceItem to_invoice_item( const QString& line,
                                        const Customer* customer,
                                        Shop* shop,
                                        const char separator = ';' );

    static std::vector< InvoiceItem > to_invoice_items( const QString& line, const char separator = ';' );
};

}      // namespace liga

#endif // INVOICESPARSER_H
